#ifndef HD44780PARALLEL_ANALYZER_SETTINGS
#define HD44780PARALLEL_ANALYZER_SETTINGS

#include <AnalyzerSettings.h>
#include <AnalyzerTypes.h>
#include <AnalyzerChannelData.h>

class HD44780AnalyzerSettings : public AnalyzerSettings
{
public:
	HD44780AnalyzerSettings();
	virtual ~HD44780AnalyzerSettings();

    enum OperationMode      {  BITS7 = 0,  BITS8 = 1, BITS11 = 2, INVALID = 3 };
    enum DataGenerationMode { INITSEQUENCE = 0, BROWNFOX = 1, TEXTBOX=2  };

	virtual bool SetSettingsFromInterfaces();
	void UpdateInterfacesFromSettings();
	virtual void LoadSettings( const char* settings );
	virtual const char* SaveSettings();
    
    OperationMode GetOperationMode(); 
    DataGenerationMode GetDataGenerationMode();
    Channel GetClock();
    U32 GetDefinedChannelsCount();
    Channel GetDefinedChannel( U32 index );
    const char* GetText();
    const char* GetModeName();
    double GetWhereToMeasurePulse() { return (double)mPositionWhereToMeasurePulse; }

    U32 GetData0();
    U32 GetData1();
    U32 GetData2();
    U32 GetData3();
    U32 GetData4();
    U32 GetData5();
    U32 GetData6();
    U32 GetData7();
    U32 GetRs();
    U32 GetRw();
    U32 GetRe();

private:
    void CreateSettingsOptions();
    void RegisterSettingOptionsWithOutsideWorld();
    void ConfigureExportOptions();
    void ReportChannelsToOutsideWorld();
    bool CalculateOperatingMode();
    void CalculateDataGenerationMode();

    inline bool AllOptionalChannelsAreUndefined();
    inline bool FirstThreeOptionalChannelsAreUndefined();
    inline bool AnyOptionalChannelIsUndefined();
    inline bool AllRequiredChannelsAreDefined();
    inline bool IsAnyChannelDefinedMoreThanOnce();
    inline void DeleteAllDataChannelInterfaces();

protected:

    std::vector< Channel >                              mDataChannels;
    std::vector< AnalyzerSettingInterfaceChannel* >     mDataChannelsInterface;
    std::auto_ptr<AnalyzerSettingInterfaceNumberList>   mDataGenerationOptions;
    std::auto_ptr<AnalyzerSettingInterfaceInteger>      mPositionToMeasurePulseOptions;
    std::auto_ptr<AnalyzerSettingInterfaceText>         mGenerationText;
    U32                                                 mOptionForDataGenerator;
    U32                                                 mPositionWhereToMeasurePulse;
    std::string                                         mTextForDataGenerator;
    std::string                                         mBinFilePath;
    std::string                                         mTextFilePath;
    OperationMode                                       mOperationMode;
    DataGenerationMode                                  mDataGenerationMode;

};

#endif //HD44780PARALLEL_ANALYZER_SETTINGS
